
from google.appengine.ext import db

class School(db.Model):
    schName = db.StringProperty(required=True)
    schAbbr = db.StringProperty(required=True)
    webUrl = db.LinkProperty()
    emailSfx = db.StringProperty(required=True)
    timestamp = db.DateTimeProperty(auto_now_add=True)
    # TODO: Finish building datasource entity
    
class Department(db.Model):
    school = db.ReferenceProperty(School, collection_name='departments')
    dName = db.StringProperty(required=True)
    dAbbr = db.StringProperty(required=True)
    timestamp = db.DateTimeProperty(auto_now_add=True)
    
class Course(db.Model):
    dept = db.ReferenceProperty(Department, collection_name='courses')
    cNo = db.IntegerProperty(required=True)
    cName = db.StringProperty(required=True)
    timestamp = db.DateTimeProperty(auto_now_add=True)
    
class BoardPost(db.Model):
    course = db.ReferenceProperty(Course, collection_name='wall_posts')
    comment_of = db.SelfReferenceProperty(collection_name='comments')
    user = db.UserProperty(auto_current_user=True)
    text = db.TextProperty(required=True)
    timestamp = db.DateTimeProperty(auto_now_add=True)

class Note(db.Model):
    course = db.ReferenceProperty(Course, collection_name='notes')
    timestamp = db.DateTimeProperty(auto_now_add=True)
